package run;

import com.SpringBootApps;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.env.StandardEnvironment;
import utils.Utils;

@Slf4j
@SpringBootTest(classes = {StartUpForRSocketServerWithWebSocket.Dummy.class},
        webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT,properties = {
        "spring.rsocket.server.transport=websocket" ,
        "spring.rsocket.server.mapping-path=/ws/"
}
)
public class StartUpForRSocketServerWithWebSocket {
    Object lock = new Object();
    @Autowired
    GenericApplicationContext context;
    @Autowired
    StandardEnvironment standardEnvironment;


    @Test
    public void verify() throws InterruptedException {

        Utils.print(context);
        String val = standardEnvironment.getProperty("spring.rsocket.server.transport");
        Assertions.assertEquals(val,"websocket");
        synchronized (lock) {
            lock.wait();
        }
    }



    @Import(value = SpringBootApps.class)
    @Configuration
    public static class Dummy {

    }

}
